/**
 * 
 */
package GUI.SplashScreen;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JWindow;

import Utils.Utils;



/**
 * @author Avia Tam
 * @author Assaf Miron
 *
 */
@SuppressWarnings("serial")
public class SplashScreen extends JWindow {
	private Integer duration;
	
	public SplashScreen(Integer dur)
	{
		// Set the Duration of the Splash Screen
		duration = dur;
	}
	
	public void showSplash()
	{
		// Get the Content Pane
		JPanel content = (JPanel) getContentPane();

		// Set the window's bounds, centering the window
		int width = 730;
		int height = 348;
		Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
		int x = (screen.width - width) / 2;
		int y = (screen.height - height) / 2;
		setBounds(x, y, width, height);
		// Create a Picture Label
		JLabel lSplashPicture = new JLabel(Utils.getImageIcon("/javanopoly.png"));
		// Add the Splash Picture
		content.add(lSplashPicture, BorderLayout.CENTER);
		// Set a Border for the Splash Screen
		content.setBorder(BorderFactory.createLineBorder(Color.black));
		// Display it
		setVisible(true);

		// Wait a little while, maybe while loading resources
		try {
		  Thread.sleep(duration);
		} catch (Exception e) {
			// No Splash? - Nevermind...
		}

		setVisible(false);	
	}

}
